package main

import (
	"github.com/robertkrimen/otto"
	"log"
)

func Potto(c int) {
	params := createParams()

	vm := otto.New()

	script, err := vm.Compile("", example)
	if err != nil {
		log.Fatal(err)
	}

	_ = vm.Set("Origin", params["Origin"])
	_ = vm.Set("Country", params["Country"])
	_ = vm.Set("Adults", params["Adults"])
	_ = vm.Set("Value", params["Value"])

	var out otto.Value

	for n := 0; n < c; n++ {
		out, err = vm.Run(script)
	}

	if err != nil {
		log.Fatal(err)
	}
	ok, err := out.ToBoolean()
	if err != nil {
		log.Fatal(err)
	}
	if !ok {
		log.Println("result error")
	}
}
